import mustache from 'mustache';
import { JSFuncs } from 'mixly';


import INIT_BEMFA_TCP_TEMPLATE from '../templates/func-init-bemfa-tcp.c';

export const init_Bemfa_TCP = function (_, generator) {
    var tcp_SERVER = generator.valueToCode(this, 'tcp_Server', generator.ORDER_ATOMIC);
    var tcp_PORT = generator.valueToCode(this, 'tcp_port', generator.ORDER_ATOMIC);
    var tcp_ClientId = generator.valueToCode(this, 'tcp_client_id', generator.ORDER_ATOMIC);
    generator.definitions_['function_startTCPClient'] = mustache.render(INIT_BEMFA_TCP_TEMPLATE, {
        server: tcp_SERVER,
        port: tcp_PORT,
        clientId: tcp_ClientId
    });
    return "doWiFiTick();\n";
}

import SUB_TOPIC_CENTER_TEMPLATE from '../templates/func-sub-topic-center.c';
import DO_TCP_CLIENT_TICK_TEMPLATE from '../templates/func-do-tcp-client-tick.c';

export const bemfa_tcp_sub_topic_rev_msg = function (_, generator) {
    var branch = generator.statementToCode(this, 'DO');
    branch = branch.replace(/(^\s*)|(\s*$)/g, "");
    branch = branch.replace(/\n/g, '\n  ');
    var funcBranch = generator.statementToCode(this, 'bemfa_function_tcp_rev_msg');
    funcBranch = funcBranch.replace(/(^\s*)|(\s*$)/g, "");
    funcBranch = funcBranch.replace(/\n/g, '\n  ');
    generator.definitions_['function_subTopicCenter'] = mustache.render(SUB_TOPIC_CENTER_TEMPLATE, { branch });
    generator.definitions_['function_doTCPClientTick'] = mustache.render(DO_TCP_CLIENT_TICK_TEMPLATE, { funcBranch });
    return "doTCPClientTick();\nsubTopicCenter();\n";
}

// 订阅主题
export const bemfa_tcp_Sub_Topic = function (_, generator) {
    var sub_topic = generator.valueToCode(this, 'tcp_sub_Topic', generator.ORDER_ATOMIC);
    var sub_code = 'subTopic(' + sub_topic + ');\n';
    return sub_code;
}

import PUBLISH_MSG_TEMPLATE from '../templates/func-publish-msg.c';

// 发布消息
export const bemfa_tcp_Pub_Topic_payload = function (_, generator) {
    var pub_topic = generator.valueToCode(this, 'pub_Topic', generator.ORDER_ATOMIC);
    var msg = generator.valueToCode(this, 'payload', generator.ORDER_ATOMIC);
    generator.definitions_['jnclude_tcp_ESP8266WiFi_var_declare_publishMsg'] = PUBLISH_MSG_TEMPLATE;
    var pub_code = 'publishMsg(' + pub_topic + ', ' + msg + ');\n';
    return pub_code;
}

// 使用帮助
export const bemfa_tcp_help = function (_, generator) {
    generator.setups_['bemfa_setup_tcp_help'] = 'Serial.println("help url: https://bemfa.com/m/tcp.html");';
    return "";
}

import RECONNECT_TEMPLATE from '../templates/func-reconnect.c';

export const init_Bemfa_Mqtt = function (_, generator) {
    var SERVER = generator.valueToCode(this, 'Server', generator.ORDER_ATOMIC);
    var PORT = generator.valueToCode(this, 'port', generator.ORDER_ATOMIC);
    generator.definitions_['include_PubSubClient'] = '#include <PubSubClient.h>';
    var ClientId = generator.valueToCode(this, 'client_id', generator.ORDER_ATOMIC);
    var UserName = generator.valueToCode(this, 'username', generator.ORDER_ATOMIC);
    var PassWord = generator.valueToCode(this, 'password', generator.ORDER_ATOMIC);
    generator.definitions_['include_reConnect'] = mustache.render(RECONNECT_TEMPLATE, {
        clientId: ClientId,
        userName: UserName,
        password: PassWord
    });
    generator.setups_['setup_initMqtt'] = 'client.setServer(' + SERVER + ', ' + PORT + ');';
    return "reConnect();\nclient.loop();";
}

// 订阅主题
export const bemfa_Sub_Topic = function (_, generator) {
    var sub_topic = generator.valueToCode(this, 'sub_Topic', generator.ORDER_ATOMIC);
    var sub_code = 'Serial.print("sub topic:");\nSerial.println(String(' + sub_topic + '));\nclient.subscribe(String(' + sub_topic + ').c_str());\ndelay(15);\n';
    return sub_code;
}

import SUB_MQTT_TOPIC_CENTER_TEMPLATE from '../templates/func-sub-mqtt-topic-center.c';
import CALLBACK_TEMPLATE from '../templates/func-callback.c';

export const bemfa_MQTT_sub_topic_rev_msg = function (_, generator) {
    generator.setups_['wsetup_initClient'] = 'client.setCallback(callback);';
    var branch = generator.statementToCode(this, 'DO', generator.ORDER_ATOMIC);
    branch = branch.replace(/(^\s*)|(\s*$)/g, "");
    branch = branch.replace(/\n/g, '\n  ');
    generator.definitions_['function_subMqttTopicCenter'] = mustache.render(SUB_MQTT_TOPIC_CENTER_TEMPLATE, { branch });
    branch = generator.statementToCode(this, 'function', generator.ORDER_ATOMIC);
    branch = branch.replace(/(^\s*)|(\s*$)/g, "");
    generator.definitions_['function_callback'] = mustache.render(CALLBACK_TEMPLATE, { branch });
    return "subMqttTopicCenter();\n";
}

export const bemfa_Mqtt_Connect_stat = function (_, generator) {
    var code = 'client.connected()';
    return [code, generator.ORDER_ATOMIC];
}

// 发布消息
export const bemfa_Pub_Topic_payload = function (_, generator) {
    var pub_topic = generator.valueToCode(this, 'pub_Topic', generator.ORDER_ATOMIC);
    if (pub_topic.indexOf("\"") < 0) {
        pub_topic = pub_topic + ".c_str()";
    }
    var msg = generator.valueToCode(this, 'payload', generator.ORDER_ATOMIC);
    var pub_code = 'client.publish( String(' + pub_topic + ').c_str(), String(' + msg + ').c_str());\nSerial.println("A message has been published");\n';
    return pub_code;
}

// 使用帮助
export const bemfa_mqtt_help = function (_, generator) {
    generator.setups_['bemfa_setup_mqtt_help'] = 'Serial.println("help url: https://bemfa.com/m/mqtt.html");';
    return "";
}

import BLOCK_CODE_BEMFA_WECHAT01_TEMPLATE from '../templates/block-code-bemfa-wechat01.c';

/***************/
export const bemfa_wechat01 = function (_, generator) {
    if (JSFuncs.getPlatform() == 'Arduino ESP8266') {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    generator.definitions_['var_declare_httpCode'] = 'int httpCode = 0;';
    //var value_buid = this.getFieldValue('buid');
    //var value_buid2 = this.getFieldValue('buid');
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_devicename = generator.valueToCode(this, 'devicename', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();
    if (value_devicename.substring(0, 1) == "\"") {
        value_devicename = value_devicename.replace(/^"|"$/g, '')
    } else {
        value_devicename = "\"+" + value_devicename + "+\"";
    }
    value_devicename = value_devicename.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();
    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    if (value_devicename == "") {
        value_devicename = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache.render(BLOCK_CODE_BEMFA_WECHAT01_TEMPLATE, {
        uid: value_buid,
        name: value_devicename,
        msg: value_devicemsg
    });
    return code;
}

import BLOCK_CODE_BEMFA_WECHAT02_TEMPLATE from '../templates/block-code-bemfa-wechat02.c';

export const bemfa_wechat02 = function (_, generator) {
    if (JSFuncs.getPlatform() == 'Arduino ESP8266') {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    generator.definitions_['var_declare_httpCode'] = 'int httpCode = 0;';
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_devicename = generator.valueToCode(this, 'devicename', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();

    if (value_devicename.substring(0, 1) == "\"") {
        value_devicename = value_devicename.replace(/^"|"$/g, '')
    } else {
        value_devicename = "\"+" + value_devicename + "+\"";
    }
    value_devicename = value_devicename.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();

    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    if (value_devicename == "") {
        value_devicename = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache.render(BLOCK_CODE_BEMFA_WECHAT02_TEMPLATE, {
        uid: value_buid,
        name: value_devicename,
        msg: value_devicemsg
    });
    return code;
}

import BLOCK_CODE_BEMFA_WECHAT03_TEMPLATE from '../templates/block-code-bemfa-wechat03.c';

export const bemfa_wechat03 = function (_, generator) {
    if (JSFuncs.getPlatform() == 'Arduino ESP8266') {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_devicetime = generator.valueToCode(this, 'devicetime', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    var value_deviceFlag = value_devicetime == "false" ? 0 : 1;

    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();

    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache.render(BLOCK_CODE_BEMFA_WECHAT03_TEMPLATE, {
        uid: value_buid,
        msg: value_devicemsg,
        time: value_deviceFlag
    });
    return code;
}

import BLOCK_CODE_BEMFA_WECHAT04_TEMPLATE from '../templates/block-code-bemfa-wechat04.c';

export const bemfa_wechat04 = function (_, generator) {
    if (JSFuncs.getPlatform() == 'Arduino ESP8266') {
        generator.definitions_['include_ESP8266WiFi'] = '#include <ESP8266WiFi.h>';
        generator.definitions_['include_ESP8266HTTPClient'] = '#include <ESP8266HTTPClient.h>';
    } else {
        generator.definitions_['include_WiFi'] = '#include <WiFi.h>';
        generator.definitions_['include_HTTPClient'] = '#include <HTTPClient.h>';
    }
    generator.definitions_['var_declare_client_bemfa_wechat'] = 'WiFiClient client_bemfa_wechat;';
    generator.definitions_['var_declare_http_bemfa_wechat'] = 'HTTPClient http_bemfa_wechat;';
    generator.definitions_['var_declare_httpCode'] = 'int httpCode = 0;';
    var value_buid = generator.valueToCode(this, 'buid', generator.ORDER_ATOMIC);
    var value_msgtitle = generator.valueToCode(this, 'msgtitle', generator.ORDER_ATOMIC);
    var value_devicemsg = generator.valueToCode(this, 'devicemsg', generator.ORDER_ATOMIC);
    if (value_buid.substring(0, 1) == "\"") {
        value_buid = value_buid.replace(/^"|"$/g, '')
    } else {
        value_buid = "\"+" + value_buid + "+\"";
    }
    value_buid = value_buid.trim();

    if (value_msgtitle.substring(0, 1) == "\"") {
        value_msgtitle = value_msgtitle.replace(/^"|"$/g, '')
    } else {
        value_msgtitle = "\"+" + value_msgtitle + "+\"";
    }
    value_msgtitle = value_msgtitle.trim();

    if (value_devicemsg.substring(0, 1) == "\"") {
        value_devicemsg = value_devicemsg.replace(/^"|"$/g, '')
    } else {
        value_devicemsg = "\"+" + value_devicemsg + "+\"";
    }
    value_devicemsg = value_devicemsg.trim();

    if (value_devicemsg == "") {
        value_devicemsg = "空";
    }
    if (value_msgtitle == "") {
        value_msgtitle = "空";
    }
    // TODO: Assemble JavaScript into code variable.
    var code = mustache.render(BLOCK_CODE_BEMFA_WECHAT04_TEMPLATE, {
        uid: value_buid,
        title: value_msgtitle,
        msg: value_devicemsg
    });
    return code;
}

// 使用帮助
export const bemfa_wechat_help = function (_, generator) {
    generator.setups_['bemfa_setup_wechat_help'] = 'Serial.println("help url: https://bemfa.com/m/we.html");';
    return "";
}

import WECHAT_CONFIG_AIRKISS_TEMPLATE from '../templates/func-wechat-config-airkiss.c';

// airkiss
export const bemfa_wechat_config_airkiss = function (_, generator) {
    generator.definitions_['include_declare_bemfa_wechat_config_airkiss'] = WECHAT_CONFIG_AIRKISS_TEMPLATE;
    generator.setups_['bemfa_setup_wechat_wifi_config'] = 'loadConfig();\n'
        + '  waitKey();\n'
        + '  initWiFi();\n';
    return "";
}

import WECHAT_CONFIG_AIRKISS_APPLUS_TEMPLATE from '../templates/func-wechat-config-airkiss-applus.c';

//airkiss
export const bemfa_wechat_config_airkiss_applus = function (_, generator) {
    var deviceProto = this.getFieldValue('deviceProto');
    var deviceType = this.getFieldValue('deviceType');
    // var deviceTypeName = '';
    // if (deviceType == "001") {
    //     deviceTypeName = "插座";
    // } else if (deviceType == "002") {
    //     deviceTypeName = "灯";
    // } else if (deviceType == "003") {
    //     deviceTypeName = "风扇";
    // } else if (deviceType == "004") {
    //     deviceTypeName = "传感器";
    // } else if (deviceType == "005") {
    //     deviceTypeName = "空调";
    // } else if (deviceType == "pic") {
    //     deviceProto = 5;
    //     deviceTypeName = "图片";
    // }
    // if (deviceType == 5) {
    //     deviceTypeName = "图片";
    // }
    // var apuid = generator.valueToCode(this, 'bemfa_wechat_ap_get_uid', generator.ORDER_ATOMIC);
    // var aptopic = generator.valueToCode(this, 'bemfa_wechat_ap_get_topic', generator.ORDER_ATOMIC);
    generator.definitions_['include_declare_bemfa_wechat_config_airkiss_plus'] = mustache.render(WECHAT_CONFIG_AIRKISS_APPLUS_TEMPLATE, {
        deviceType,
        version: deviceProto
    });
    generator.setups_['setup_wechat_wifi_airkiss_config_plus'] = 'String topic = WiFi.macAddress().substring(8);//取mac地址做主题用\n'
        + '  topic.replace(":", "");//去掉:号\n'
        + '  loadConfig();//加载存储的数据\n'
        + '  waitKey();//检查是否需要airkiss配网\n'
        + '  initWiFi();//初始化wifi信息，并连接路由器网络\n'
        + '  getUid(topic);//获取密钥\n';
    return "";
}

import WECHAT_CONFIG_AP_TEMPLATE from '../templates/func-wechat-config-ap.c';
import BLOCK_SETUP_WECHAT_CONFIG_AP_TEMPLATE from '../templates/block-setup-wechat-config-ap.c';

//airkiss
export const bemfa_wechat_config_ap = function (_, generator) {
    generator.definitions_['include_declare_bemfa_wechat_config_airkiss'] = WECHAT_CONFIG_AP_TEMPLATE;
    generator.setups_['bemfa_setup_wechat_wifi_apconfig'] = BLOCK_SETUP_WECHAT_CONFIG_AP_TEMPLATE.replace(/\n/g, '\n  ');
    return "";
}

import WECHAT_CONFIG_APPLUS_TEMPLATE from '../templates/func-wechat-config-applus.c';
import BLOCK_SETUP_WECHAT_CONFIG_APPLUS_TEMPLATE from '../templates/block-setup-wechat-config-applus.c';

//airkiss
export const bemfa_wechat_config_applus = function (_, generator) {
    var deviceProto = this.getFieldValue('deviceProto');
    var deviceType = this.getFieldValue('deviceType');
    var deviceTypeName = '';
    if (deviceType == "001") {
        deviceTypeName = "插座";
    } else if (deviceType == "002") {
        deviceTypeName = "灯";
    } else if (deviceType == "003") {
        deviceTypeName = "风扇";
    } else if (deviceType == "004") {
        deviceTypeName = "传感器";
    } else if (deviceType == "005") {
        deviceTypeName = "空调";
    } else if (deviceType == "pic") {
        deviceProto = 5;
        deviceTypeName = "图片";
    }
    if (deviceType == 5) {
        deviceTypeName = "图片";
    }
    // var apuid = generator.valueToCode(this, 'bemfa_wechat_ap_get_uid', generator.ORDER_ATOMIC);
    // var aptopic = generator.valueToCode(this, 'bemfa_wechat_ap_get_topic', generator.ORDER_ATOMIC);
    generator.definitions_['include_declare_bemfa_wechat_config_airkiss'] = mustache.render(WECHAT_CONFIG_APPLUS_TEMPLATE, {
        deviceType,
        deviceName: deviceTypeName,
        protoVersion: deviceProto
    });
    generator.setups_['include_setup_wechat_wifi_apconfig'] = BLOCK_SETUP_WECHAT_CONFIG_APPLUS_TEMPLATE.replace(/\n/g, '\n  ');
    return "";
}

// 恢复出厂
export const bemfa_wechat_reBegin = function () {
    var code = 'Serial.println(" Restore Factory....... ");\n'
        + 'config.magic = 0x00;\n'
        + 'strcpy(config.stassid, "");\n'
        + 'strcpy(config.stapsw, "");\n'
        + 'strcpy(config.cuid, "");\n'
        + 'strcpy(config.ctopic, "");\n'
        + 'config.magic = 0x00;\n'
        + 'saveConfig();\n'
        + 'delayRestart(1);\n'
    return code;
}

// 使用帮助
export const bemfa_wechat_config_help = function (_, generator) {
    generator.setups_['bemfa_setup_wechat_help'] = 'Serial.println("help url: https://bemfa.com/m/m.html");';
    return "";
}

import ESP32_CAM_TEMPLATE from '../templates/func-esp32-cam.c';
import BLOCK_SETUP_ESP32_CAM_TEMPLATE from '../templates/block-setup-esp32-cam.c';

//esp32 拍照上传
export const init_Bemfa_ESP_cam = function (_, generator) {
    var bemfa_uid = generator.valueToCode(this, 'esp32cam_client_id', generator.ORDER_ATOMIC);
    var bemfa_topic_id = generator.valueToCode(this, 'esp32cam_topic_id', generator.ORDER_ATOMIC);
    var bemfa_wechat_msg = generator.valueToCode(this, 'bemfa_push_cam_wechat_msg', generator.ORDER_ATOMIC);
    var bemfa_wechat_msg_cam = generator.valueToCode(this, 'bemfa_push_cam_wechat_cam_msg', generator.ORDER_ATOMIC);
    var bemfa_wechat_cam_path = generator.valueToCode(this, 'bemfa_push_cam_wechat_cam_path', generator.ORDER_ATOMIC);
    var value_esp32cam_falsh_led = generator.valueToCode(this, 'esp32cam_falsh_led', generator.ORDER_ATOMIC);

    if (bemfa_wechat_msg == '"空"') {
        bemfa_wechat_msg = '""';
    }
    if (bemfa_wechat_msg_cam == '"空"') {
        bemfa_wechat_msg_cam = '""';
    }
    if (bemfa_wechat_cam_path == '"空"') {
        bemfa_wechat_cam_path = '""';
    }

    if (bemfa_uid.substring(0, 1) != "\"") {
        bemfa_uid = bemfa_uid + '.c_str()'
    }
    if (bemfa_topic_id.substring(0, 1) != "\"") {
        bemfa_topic_id = bemfa_topic_id + '.c_str()'
    }
    if (bemfa_wechat_msg.substring(0, 1) != "\"") {
        bemfa_wechat_msg = bemfa_wechat_msg + '.c_str()'
    }
    if (bemfa_wechat_msg_cam.substring(0, 1) != "\"") {
        bemfa_wechat_msg_cam = bemfa_wechat_msg_cam + '.c_str()'
    }
    if (bemfa_wechat_cam_path.substring(0, 1) != "\"") {
        bemfa_wechat_cam_path = bemfa_wechat_cam_path + '.c_str()'
    }
    var funcBranch = generator.statementToCode(this, 'bemfa_function_pic_rev');
    funcBranch = funcBranch.replace(/(^\s*)|(\s*$)/g, "");
    generator.definitions_['include_var_declare_bemfa_cam_pic'] = mustache.render(ESP32_CAM_TEMPLATE, {
        flashLed: value_esp32cam_falsh_led,
        uid: bemfa_uid,
        topicId: bemfa_topic_id,
        wechatMsg: bemfa_wechat_msg,
        wechatMsgCam: bemfa_wechat_msg_cam,
        wechatCamPath: bemfa_wechat_cam_path,
        funcBranch
    });
    generator.setups_['bemfa_setup_bemfa_cam_pic'] = BLOCK_SETUP_ESP32_CAM_TEMPLATE;
    return "take_send_photo();";
}


//使用帮助
export const bemfa_wechat_esp32cam_config_help = function (_, generator) {
    generator.setups_['bemfa_wechat_esp32cam_config_help'] = 'Serial.println("help url: https://bemfa.com/m/c.html");';
    return "";
}

import INIT_BEMFA_OTA_UPDATE_TEMPLATE from '../templates/func-init-bemfa-ota-update.c';
import BLOCK_CODE_INIT_BEMFA_OTA_UPDATE_TEMPLATE from '../templates/block-code-init-bemfa-ota-update.c';

//使用帮助
export const init_bemfa_ota_updata = function (_, generator) {
    // var type = this.getFieldValue('type');
    var otaUrl = generator.valueToCode(this, 'init_bemfa_ota_updata_url', generator.ORDER_ATOMIC);
    generator.definitions_['var_declear_ESP8266WiFiota001'] = INIT_BEMFA_OTA_UPDATE_TEMPLATE;
    return mustache.render(BLOCK_CODE_INIT_BEMFA_OTA_UPDATE_TEMPLATE, { otaUrl });
}

// 使用帮助
export const bemfa_ota_config_help = function (_, generator) {
    generator.setups_['bemfa_ota_config_help'] = 'Serial.println("help url: https://bemfa.com/m/ota.html");';
    return "";
}